package com.costeaalex.blueserver.threads;

import javax.comm.CommPort;

import com.costeaalex.blueserver.comm.COMServer;
import com.costeaalex.blueserver.communication.CommunicationManager;
import com.costeaalex.blueserver.timeout.TimeoutProcess;

public class StartCOMServer  extends Thread implements TimeoutProcess
	{

	private COMServer cS;
	private CommunicationManager cM;
	private boolean cancellable=true;
	private MainThread mTL;
	
	public String name="COM Port";
	
	public StartCOMServer(MainThread mT,CommPort cP)
		{ 
		cS=new COMServer(cP);
		mTL=mT;
		}
	
	@Override
	public void run()
		{
		super.run();
		cS.start();
		cancellable=false;
		cM=cS;
		mTL.COMServerStatus(cM);
		}
	
	public void destroy()
		{
		cS=null;
		if(cancellable)
			mTL.operationCancelled(this);
		if(isAlive())
			this.interrupt();
		}

	public boolean isCancellable()
		{
		return cancellable;
		}

	public String getProcessName()
		{
		return name;
		}
	
	}
